import kotlinx.browser.document
import kotlinx.browser.window
import three.*
import kotlin.js.json

fun main() {
    val scene = Scene()
    val camera = PerspectiveCamera(75.0, window.innerWidth.toDouble() / window.innerHeight, 0.1, 1000.0)
    camera.position.z = 5f

    val geometry = BoxGeometry(1f, 1f, 1f)
    val material = MeshBasicMaterial(json("color" to 0x0000ff))
    val cube = Mesh(geometry, material)
    scene.add(cube)

    val renderer = WebGLRenderer()
    renderer.setSize(window.innerWidth, window.innerHeight)
    renderer.setAnimationLoop {
        cube.rotation.x += 0.01f;
        cube.rotation.y += 0.01f;

        renderer.render(scene, camera)
    }
    document.body?.appendChild(renderer.domElement)

}
